//
//  ServiceIncomeViewController.m
//  AnXin100
//
//  Created by Sakura on 2018/11/10.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "ServiceIncomeViewController.h"
#import "ServiceIncomeTableViewCell.h"
@interface ServiceIncomeViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *mainTable;
@end

@implementation ServiceIncomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.mainTable];
    
    
    UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    headView.backgroundColor = [UIColor whiteColor];
    
    
    NSArray *array = @[@"200.00\n累计收入", @"200.00\n当前余额"];
    NSArray *childAry = @[@"累计收入", @"当前余额"];
    for (NSInteger i = 0; i < array.count; i++) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2 * i, 0, SCREEN_WIDTH / 2, 80)];
        label.font = [UIFont systemFontOfSize:16];
        label.textColor = COLOR_ORG;
        label.text = array[i];
        label.numberOfLines = 0;
        label.textAlignment = NSTextAlignmentCenter;
        NSMutableAttributedString *attribut = [[NSMutableAttributedString alloc]initWithString:label.text];
        
        NSRange range = [label.text rangeOfString:childAry[i]];
        [attribut addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14]range:range];
        [attribut addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHex:0x999999] range:range];
        
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        paragraphStyle.lineSpacing = 10; // 调整行间距
        paragraphStyle.alignment = NSTextAlignmentCenter;
        NSRange allRange = NSMakeRange(0, [label.text length]);
        [attribut addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:allRange];
        label.attributedText = attribut;

        [headView addSubview:label];
        
        if (i == 1) {
            UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 79, SCREEN_WIDTH, 1)];
            lineView.backgroundColor = COLOR_LINE;
            [headView addSubview:lineView];
            
            UIView *verticalLine = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2 - 0.5, 0, 1, 80)];
            verticalLine.backgroundColor = COLOR_LINE;
            [headView addSubview:verticalLine];
        }
    }
    _mainTable.tableHeaderView = headView;
}


- (UITableView *)mainTable {
    if (!_mainTable) {
        _mainTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - Hn - 44) style:UITableViewStylePlain];
        _mainTable.delegate = self;
        _mainTable.dataSource = self;
        [_mainTable registerClass:[ServiceIncomeTableViewCell class] forCellReuseIdentifier:@"ServiceIncomeTableViewCell"];
    }
    return _mainTable;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 60;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ServiceIncomeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ServiceIncomeTableViewCell"];
    return cell;
}



@end
